{__NOLAYOUT__}
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>代理商管理</title>
    <link rel="stylesheet" type="text/css" href="/agent/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="/agent/css/agent_list.css"/>
    <script type="text/javascript" src="/agent/js/jquery-2.1.0.js"></script>
    <script type="text/javascript" src="/agent/js/rem.js" ></script>
    <script type="text/javascript" src="/agent/js/mescroll.min.js" ></script>
    <link rel="stylesheet" type="text/css" href="/agent/css/mescroll.min.css"/>
</head>
<body>
<div class="nr">
    <div class="sousuo">
        <input type="text" name="" id="search" value="" placeholder="搜索内容" />
        <img src="/agent/img/sousuo.png"/>
    </div>
    <div id="mescroll"  class="mescroll">
        <ul class="foreach">

        </ul>
    </div>
    {if $auth->check('agent/info/mobileadd')}
        <a class="add_agent" href="mobileAdd">添加代理商</a>
    {/if}
</div>
<script>
  var offset = 0; //页码
  var limit = 10;  //每页数据固定条数
  var param = window.location.search;
  $('#search').change(function () {
    offset = 0;
    limit = 10;
    param = $('#search').val();
    $("#mescroll li").remove();
    upCallback()
  });
  //创建MeScroll对象
  var mescroll = new MeScroll("mescroll", {
    up: {
      callback: upCallback //上拉加载的回调
       ,
      htmlNodata: '<p class="upwarp-nodata">-- 暂无更多数据 --</p>',
      empty: {
        //列表第一页无任何数据时,显示的空提示布局; 需配置warpId或clearEmptyId才生效;
        warpId:'mescroll', //父布局的id; 如果此项有值,将不使用clearEmptyId的值;
        icon: null, //图标,默认null
        tip: "暂无更多数据~", //提示
        btntext: "", //按钮,默认""
        btnClick: null, //点击按钮的回调,默认null
      },
    }
  });
  //上拉加载的回调 page = {num:1, size:5}; num:当前页 默认从1开始, size:每页数据条数,默认5
  function upCallback(page) {
    $.ajax({
      url: '/admin/agent/info/mobileindex?search='+param+'&offset='+offset+'&limit='+limit,
      dataType:'json',
      type:'GET',
      success: function(json) {
        offset += limit++;
        limit = 10;
        $('.foreach').append(render(json));
        mescroll.endByPage(json.rows.length, json.total);
      },
      error: function(e) {
        //联网失败的回调,隐藏下拉刷新和上拉加载的状态
        mescroll.endErr();
      }
    });
  }
  function render(data)
  {
    var html ='';
    $.each(data.rows,function (index,value) {
      html +='<li>'+'<a href="/admin/agent/info/mobileedit/ids/'+value.id+'"><p>'+value.agent_name+'</p></a>'
        +'<p><img src="/agent/img/sou.png"/>'+value.province_text+value.city_text+value.area_text+value.address+'</p>'
        +'<p><img src="/agent/img/tel.png"/><a href="tel:'+value.agent_phone+'">'+value.agent_phone+'</a></p>'
        +'<p><img src="/agent/img/per.png"/>'+value.agent_contact+'</p><div class="chakan"><span><a href="mobileBill/agentid/'+value.id+'">查看账单</a></span><span><a href="mobileOrder/agentid/'+value.id+'">查看订单</a></span></div></li>';
    });
    return html;
  }
</script>
</body>
</html>